const { defineConfig } = require('@vue/cli-service')
const NodePolyfillPlugin = require('node-polyfill-webpack-plugin')

module.exports = defineConfig({
	transpileDependencies: true,
	lintOnSave:false,
	chainWebpack: config => {
		config.module.rule('wasm').test(/\.wasm$/).type('javascript/auto')
	},
	chainWebpack(config) {
		config.module
		  .rule('worker')
		  .test(/\.worker\.js$/)
		  .use('worker-loader')
		  .loader('worker-loader')
		  .end();
		config.module.rule('js').exclude.add(/\.worker\.js$/)
	},

	configureWebpack:{
	  resolve:{
		  extensions: ['.dev.js', '.js', '.json', '.wasm'],
		  fallback: {
		    crypto: false,
		    path: false,
		    fs: false
		  },
	  },
	  plugins:[
		  new NodePolyfillPlugin()
		]
	},
	devServer:{
	  host:'localhost',
	  port:3000,
	  headers: {
	    'Cross-Origin-Opener-Policy': 'same-origin',
	    'Cross-Origin-Embedder-Policy': 'require-corp'
	  }
	}
})
